package com.ck.express.tcp

import android.util.Log
import io.netty.buffer.ByteBuf
import io.netty.buffer.Unpooled
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.ByteToMessageDecoder

class DebugDecoder : ByteToMessageDecoder() {
    override fun decode(ctx: ChannelHandlerContext, `in`: ByteBuf, out: MutableList<Any>) {
        val readable = `in`.readableBytes()
        if (readable > 0) {
            val bytes = ByteArray(readable)
            `in`.readBytes(bytes)
            Log.i("DebugDecoder", "收到字节: ${bytes.joinToString(",")}")
            out.add(Unpooled.wrappedBuffer(bytes))
        }
    }
}